home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / StdEnv / StdFunc.dcl < prev    next >
Text File  |  1996-12-23  |  1KB  |  31 lines

  1. definition module StdFunc
  2.  
  3. // ****************************************************************************************
  4. //    Concurrent Clean Standard Library Module Version 1.1
  5. //    Copyright 1995 University of Nijmegen
  6. // ****************************************************************************************
  7.  
  8. // Some Classical Functions:
  9.  
  10. I                    :: !.a -> .a                                // Identity function
  11. K                    :: !.a .b -> .a                                // Konstant function
  12. S :: !.(a -> .(.b -> .c)) .(a -> .b) a -> .c                    // Distribution function
  13. flip                :: !.(.a -> .(.b -> .c)) .b .a -> .c            // Flip arguments
  14.  
  15. (o)        infixr  9    ::  u:(.a -> .b) u:(.c -> .a) -> u:(.c -> .b)// Function composition
  16.  
  17. twice                ::                 !(.a -> .a) .a    -> .a        // f (f x)
  18. while                :: !(a -> .Bool) (a -> a)      a     ->  a        // while (p x) f (f x) 
  19. until                :: !(a -> .Bool) (a -> a)      a     ->  a        // f (f x) until (p x)
  20. iter                :: !Int          (.a -> .a) .a    -> .a        // f (f..(f x)..) 
  21.  
  22. //    Some handy functions for transforming unique states:
  23.  
  24. ::St s a :== s -> (a,s)
  25.  
  26. seq                 :: ![.(.s -> .s)] .s -> .s                    // fn-1 (..(f1 (f0 x))..)
  27. seqList                :: ![St .s .a] .s -> ([.a],.s)                // fn-1 (..(f1 (f0 x))..)
  28.                                                                 // monadic style:
  29. (`bind`) infix 0 :: w:(St .s .a) v:(.a -> .(St .s .b)) -> u:(St .s .b), [u <= v, u <= w]
  30. return                :: u:a -> u:(St .s u:a)
  31.